/***************************************************************
*  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
*  All rights reserved.
*
*  This file is part of the GroupMe! Project. Source code of 
*  this project is closed and redistribution of this code is
*  prohibited. 
*  
*  Contact: http://www.groupme.net
*
*  This copyright notice MUST APPEAR in all copies of the file!
***************************************************************/
package net.groupme.gui.rendering;

import java.util.HashMap;
import java.util.Map;

import net.groupme.gui.rendering.constants.RENDERING_CONSTANTS;
import net.groupme.model.MODEL_CONSTANTS;

/**
 * created on Jun 29, 2007
 * 
 * This class offers some utility methods which e.g. allow to map from 
 * the type of a resource to the recommended Renderer.
 * 
 * @author Fabian Abel, <a href="mailto:abel@l3s.de">abel@l3s.de</a>
 * @author last edited by: $Author: mischa $
 * 
 * @version $Revision: 1.6 $ $Date: 2007-10-09 14:48:18 $
 */
public class RenderingUtility {

	/** maps from the type of resource to the suggested renderer bean */
	private static Map<String, String> typeRendererIDMapping = new HashMap<String, String>();
	
	static{
		typeRendererIDMapping.put(MODEL_CONSTANTS.RESOURCE_TYPE_WEBSITE, RENDERING_CONSTANTS.RENDERER_DEFAULT);
		typeRendererIDMapping.put(MODEL_CONSTANTS.RESOURCE_TYPE_IMAGE, RENDERING_CONSTANTS.RENDERER_IMAGE);
		typeRendererIDMapping.put(MODEL_CONSTANTS.RESOURCE_TYPE_SHOCKWAVE, RENDERING_CONSTANTS.RENDERER_SHOCKWAVE);
		typeRendererIDMapping.put(MODEL_CONSTANTS.RESOURCE_TYPE_VIDEO, RENDERING_CONSTANTS.RENDERER_VIDEO);
		typeRendererIDMapping.put(MODEL_CONSTANTS.RESOURCE_TYPE_AUDIO, RENDERING_CONSTANTS.RENDERER_VIDEO);
		typeRendererIDMapping.put(MODEL_CONSTANTS.RESOURCE_TYPE_RSS, RENDERING_CONSTANTS.RENDERER_RSS);
		typeRendererIDMapping.put(MODEL_CONSTANTS.RESOURCE_TYPE_GROUP, RENDERING_CONSTANTS.RENDERER_GROUP);
	}
	
	/**
	 * This method suggests a rendering bean fo a given type (as defined in {@link MODEL_CONSTANTS}).
	 * 
	 * @param type the type (as defined in {@link MODEL_CONSTANTS})
	 * @return the corresponding suggested renderer id (as defined in {@link RENDERING_CONSTANTS}).
	 */
	public static String suggestRenderer(String type){
		if(typeRendererIDMapping.containsKey(type)){
			return typeRendererIDMapping.get(type);
		}
		return RENDERING_CONSTANTS.RENDERER_DEFAULT;
	}
}
